﻿Imports System.Data.OleDb
Public Class detail
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("AudiCon").ConnectionString)
        Dim SqlString As String = "Insert into Comments(Author,Titles,Comment,Audi_fk) Values (@f1,@f2,@f3,@f4)"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", TextBox1.Text)
        cmd.Parameters.AddWithValue("@f2", TextBox2.Text)
        cmd.Parameters.AddWithValue("@f3", TextBox3.Text)
        cmd.Parameters.AddWithValue("@f4", Request.Params("ID"))


        oleDbConn.Open()
        cmd.ExecuteNonQuery()

        Response.Redirect("commentConfirmation.aspx")
    End Sub

    Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("AudiCon").ConnectionString)
        Dim SqlString As String = "Insert into TagJunction(Audi_fk,Tag_fk) Values (@f1,@f2)"
        oleDbConn.Open()

        For Each cb As ListItem In CheckBoxList1.Items
            If cb.Selected Then

                Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
                cmd.CommandType = CommandType.Text
                cmd.Parameters.AddWithValue("@f1", Request.Params("ID"))
                cmd.Parameters.AddWithValue("@f2", cb.Value)
                cmd.ExecuteNonQuery()

            End If

        Next
    End Sub
End Class